package org.swidgets.server.sgrid;

import org.swidgets.sgrid.TestService;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class TestServiceServlet extends RemoteServiceServlet implements
		TestService {

	private static final long serialVersionUID = 1L;
	private static final int maxRecord=25;
	
	private final static String[][] stringServerData = new String[maxRecord][3];
	static {
		
		for(int i=0;i<stringServerData.length;i++){
			stringServerData[i][0] = "S-nome "+i;
			stringServerData[i][1] = "S-cognome "+i;
			stringServerData[i][2] = "S-ruolo "+i;
		}
	}
	
	
	public String[][] getData(int start, int limit) {
		String[][] ret=new String[limit][3];
		int first=Math.min(start, maxRecord-1);
		int last=Math.min(first+limit, maxRecord);
		int rec=last-first;
		for(int i=0;i<rec;i++){
			ret[i][0]=stringServerData[i+first][0];
			ret[i][1]=stringServerData[i+first][1];
			ret[i][2]=stringServerData[i+first][2];
		}
		return ret;
	}

}
